package com.gaga.console.core.service.impl;

import com.alibaba.fastjson.JSON;
import com.gaga.common.constant.BvConstants;
import com.gaga.console.base.utils.RestUtils;
import com.gaga.console.core.entity.dto.SubmitAdviceDto;
import com.gaga.console.core.entity.req.SubmitAdviceReq;
import com.gaga.console.core.service.BvAdviceService;
import com.gaga.console.core.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author liujia
 * @since 2025-04-06
 */
@Slf4j
@Service
public class BvAdviceServiceImpl implements BvAdviceService {

    @Autowired
    private SysConfigService sysConfigService;

    @Override
    public void submitAdvice(SubmitAdviceDto dto) {
        if (StringUtils.isBlank(dto.getAdviceText())) {
            throw new IllegalArgumentException("意见反馈内容不能为空");
        }

        String feishuSendMsgUrl = sysConfigService.getConfigValueByKey(BvConstants.FEISHU_SENDMSG_URL);

        SubmitAdviceReq submitAdviceReq = new SubmitAdviceReq();
        SubmitAdviceReq.AdviceContent adviceContent = new SubmitAdviceReq.AdviceContent();
        adviceContent.setText(dto.getAdviceText());
        submitAdviceReq.setContent(adviceContent);

        RestUtils.post(feishuSendMsgUrl, JSON.toJSONString(submitAdviceReq));
    }
}
